package com.ibsol.service
{
	import com.ibsol.database.WeatherDAO;
	import com.ibsol.model.Weather;
	
	public class WeatherService{
		
		private var weatherDAO:WeatherDAO;
		
		public function WeatherService(){
			weatherDAO=new WeatherDAO();
		}
		
		/**
		 * 根据城市id得到天气信息
		 **/
		 public function getWeatherByCityId(cityid:int):Weather{
		 	var weather:Weather=null;
		 	this.weatherDAO.getWeatherByCityId(cityid,function (w:Weather):void{
		 		weather=w;
		 	});
		 	return weather;
		 }
		 /**
		 *通过城市编号更新城市的天气情况 ，从yahoo weatherService中得到的数据
		 **/
		 public function updateWeatherById(weather:Weather):Boolean{
		 	var flag:Boolean=false;//失败
		 	this.weatherDAO.updateWeatherById(weather,function ():void{
		 		flag=true;//成功
		 	});
		 	return flag;
		 }
		 
		 /**
		 * 添加城市的天气情况
		 **/
		 public function insertWeather(weather:Weather):Boolean{
		 	var flag:Boolean=false;
		 	this.weatherDAO.insertWeather(weather,function ():void{
		 		flag=true;
		 	});
		 	return flag;
		 }
		 
		 /**
		 * 手动修改---->按城市编号修改当前温度
		 **/
		 public function updateCelCiusById(cityid:int,celcius:String):Boolean{
		 	var flag:Boolean=false;
		 	this.weatherDAO.updateCelCiusById(cityid,celcius,function ():void{
		 		flag=true;
		 	});
		 	return flag;
		 }
	}
}